#!/usr/bin/env python
"""
    Created by huangyi at 2020/1/11.
    Copyright (c) 2013-present, Xiamen Dianchu Technology Co.,Ltd.
    Description:
    Changelog: all notable changes to this file will be documented
"""
from app.expression.context import Context
from app.expression.nonterminal.div_expression import DivExpression
from app.expression.nonterminal.multi_expression import MultiExpression
from app.expression.nonterminal.plus_expression import PlusExpression
from app.expression.nonterminal.sub_expression import SubExpression
from app.expression.terminal.float_expression import FloatExpression
from app.expression.terminal.int_expression import IntExpression

if __name__ == '__main__':
    # (1+2*3-4)/1.5
    num1 = IntExpression(str(1))
    num2 = IntExpression(str(2))
    num3 = IntExpression(str(3))
    num4 = IntExpression(str(4))
    num1_5 = FloatExpression(str(1.5))

    multi = MultiExpression(num2, num3)
    plus = PlusExpression(num1, multi)
    sub = SubExpression(plus, num4)
    div = DivExpression(sub, num1_5)

    print("(1+2*3-4)/1.5={}".format(div.interpret(Context())))
